package com.sunkey.controller;

import java.util.concurrent.Callable;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sunkey.domain.User;
import com.sunkey.service.UserService;


/**
 * 异步api示例
 *
 * @author sunkey
 * @date Feb 28, 2015
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/get")
    public Callable<User> getUser() {
        System.out.println("=====hello");
        return new Callable<User>() {
            @Override
            public User call() throws Exception {
                Thread.sleep(10L * 1000); 
                User user = userService.getUser();
                user.setName("haha");
                return user;
            }
        };
    }
}